﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class WordHeaderFooter
    {
        private readonly object _lock = new object();

        public bool LinkToPrevious
        {
            get { return _headerFooter.LinkToPrevious; }
        }

        private WordRange _range;
        public WordRange Range
        {
            get
            {
                if (_range == null)
                {
                    lock (_lock) { if (_range == null) { _range = new WordRange(_headerFooter.Range) { Document = Section.Document }; } }
                }
                return _range;
            }
        }

        private WordPageNumbers _pageNumbers;
        public WordPageNumbers PageNumbers
        {
            get
            {
                if (_pageNumbers == null)
                {
                    lock (_lock) { if (_pageNumbers == null) { _pageNumbers = new WordPageNumbers(_headerFooter.PageNumbers); } }
                }
                return _pageNumbers;
            }
        }

        private HeaderFooter _headerFooter;

        public WordSection Section
        {
            get;
            internal set;
        }

        internal WordHeaderFooter(HeaderFooter headerFooter)
        {
            _headerFooter = headerFooter;
        }
    }
}
